package acwing._1_1AlgorithmBasic._3SearchGraph;
/**
 * @Project : AlgorithmLearning
 * @Package : ACWing._1_1AlgorithmBasic._3SearchGraph
 * @File : Q0846.java
 * @Author : WangRuoyu
 * @Date : 2023/4/2 9:14
 */

import java.io.*;
import java.util.Arrays;

public class Q0846 {
    static int n;
    static int[] h;
    static int[] e;
    static int[] next;
    static boolean[] st;
    static int idx = 0;
    static int res = 0x3f3f3f3f;

    static void add(int a, int b) {
        e[idx] = b;
        next[idx] = h[a];
        h[a] = idx++;
    }

    static int dfs(int u) {
        st[u] = true;
        int sum = 0;
        int maxCnt = 0;
        for (int i = h[u]; i != -1; i = next[i]) {
            int j = e[i];
            if (!st[j]) {
                int cnt = dfs(j);
                sum += cnt;
                maxCnt = Math.max(maxCnt, cnt);
            }
        }
        maxCnt = Math.max(maxCnt, n - 1 - sum);
        res = Math.min(res, maxCnt);
        return sum + 1;
    }

    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        String[] words = br.readLine().split(" ");
        n = Integer.parseInt(words[0]);
        h = new int[n + 1];
        e = new int[2 * n + 10];
        next = new int[2 * n + 10];
        st = new boolean[n + 1];
        Arrays.fill(h, -1);

        for (int i = 0; i < n - 1; ++i) {
            words = br.readLine().split(" ");
            int a = Integer.parseInt(words[0]);
            int b = Integer.parseInt(words[1]);
            add(a, b);
            add(b, a);
        }

        dfs(1);

        System.out.println(res);
    }
}

